/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jay9downloader;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JList;
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;

/**
 *
 * @author Jonas
 */
public class Videos implements ListModel {

    private BlipDay9Tv blip;
    private List<ListDataListener> listeners;
    private List<Video> videos;

    public Videos() {
        super();
        listeners = new ArrayList<ListDataListener>();
        videos = new ArrayList<Video>();
        try {
            blip = new BlipDay9Tv();
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Videos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Videos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Videos.class.getName()).log(Level.SEVERE, null, ex);
        }
        videos.addAll(blip.getVideos());
    }

    public Object getElementAt(int index) {
        return videos.get(index);
    }

    public void addListDataListener(ListDataListener l) {
        listeners.add(l);
    }

    public void removeListDataListener(ListDataListener l) {
        listeners.remove(l);
    }

    public int getSize() {
        return videos.size();
    }

}
